FTP_SCRIPT_RUN_SILENT Function
Syntax
Arguments
- Result
The return value is only meaningful if Modal is set to .F. See the Modal description.
- ftp_scriptCharacter
A CR-LF delimited list of FTP commands to execute (See FTP Command Syntax below)
- modalLogical
Default = .T..
If .T., the function runs synchronously, meaning that Xbasic pauses until the FTP transfer is complete. When the function is complete, Result will be set to either "Transfer completed" or "Error". There is no need to supply the FTPStatus parameter.
If .F., the function runs asynchronously, meaning that Xbasic continues to execute while the FTP transfer continues in a background thread. In this case, the FTPStatus argument should be supplied. FTPStatus.message contains the status of the FTP transfer.
- FTPStatusPointer
Default = null_value().
FTPStatus should be supplied if modal is set to .F..
Description
Run an Alpha Anywhere FTP script. Alpha Anywhere has a simple "FTP language" that can be used to write scripts that execute various FTP commands such as uploading and downloading files, making folders on the remove FTP target, renaming and deleting files and folders, etc. This function executes a FTP script created by FTP_MakeCommandList() without a user dialog.
FTP Command Syntax
- Command
- Description
- connect| Address
Connects to an FTP site specified by Address
- login| User | Password
Logs in to an FTP site.
- list| Optional_Mask
Lists files on a FTP site and places the result in the List_Result variable. The Eval command can use List_Result. To list only files that match a mask, specify the Optional_Mask.
- nlist| Optional_Mask
Lists files (filenames only, no additional information) on a FTP site and places the result in the List_Result variable. This variable can be used in the Eval command.
To list only files that match a mask, specify the Optional_Mask.
- quit
End the FTP session.
- cd| Path
Change the working directory on the FTP site.
- binary
Execute this command before transferring a binary file.
- ascii
Execute this command before transferring an ASCII file
- pwd
Returns the name of the current working directory (i.e. folder) on the FTP site and places it in the Result variable which can be used in an expression with the Eval command
- rm| File_Name
Deletes a file on the FTP site
- mkdir| Folder_Name
Makes a folder on the FTP site.
- rmdir| Folder_Name
Deletes a folder on the FTP site.
- rename| Old_File_Name | New_File_Name
Renames a file on the FTP site.
- get| Remote_File_Name | Local_File_Name
Transfers a file from the FTP site to the local machine.
- put| Local_File_Name | Remote_File_Name
Transfers a file from the local machine to the FTP site.
Advanced FTP Command Syntax
- Command
- Description
- eval| Expression
Evaluates Expression and then executes the resulting command. The eval command, in effect, allows you to dynamically generate FTP commands to be executed. The Expression can reference the following special variables: Result = Result of last FTP command (e.g. error code returned, path returned by PWD command, etc.)
List_Result = List of files returned by LIST or NLIST command.
- onerror| Command
If the prior FTP command fails, then the Command specified by onerror is executed.
- log| Text
Concatenates text to the status text displayed by the progress dialog box.
- error| Text
Reports an error and quits the session.
- replace| Searchtext | Replacetext
Modifies the commands that follow in the script. An example of how this might be used is to replace a placeholder in the script with the folder name that is retrieved through the pwd command.
Example
DIM myStatus as P DIM myStatus.message as C result = FTP_SCRIPT_RUN_SILENT(FtpScript, .f., myStatus)
This example includes a variable named varc_filenmedir. It cannot be quoted, so it is placed between 2 strings.
cmd = <<%a% connect|ftp.mysite.com onerror|error|Could not connect login|user|password onerror|error|Could not log in cd|\newuser binary put|%a% + varc_filenmedir + crlf() + <<%a% quit %a% Result = FTP_SCRIPT_RUN_SILENT(cmd)
See Also